<!DOCTYPE html>
<html lang="">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta itemprop="name" content="Php安装">
<meta itemprop="description" content="php安装  在./docker-compose中，增加service，实例如下
 version: &#34;3.7&#34;services:# php-fpmphp:image: devilbox/php-fpm:7.2-prodcontainer_name: &#34;php&#34;depends_on:- mysql- redisenvironment:- TZ=Asia/Shanghaivolumes:# 配置挂载到容器，在第一次启动容器后，复制出来，然后重建容器# - ./php/etc:/usr/local/etc# 数据卷挂载到容器- ./front:/front- ./back:/back# 以root方式启动command:- php-fpm- -Rlogging:driver: json-fileoptions:max-size: &#34;10M&#34;max-file: &#34;10&#34;restart: alwaysphp配置  修改php配置，使其以root角色启动，否则容易出现文件夹读写权限的问题
  容器php-fpm以root方式启动  command:- php-fpm- -R 修改./php/etc/php-fpm.conf  ############################################################; User and Group; ############################################################[www]user = rootgroup = root 配置.">
<meta itemprop="datePublished" content="2023-03-16T11:08:40&#43;08:00" />
<meta itemprop="dateModified" content="2023-03-16T11:08:40&#43;08:00" />
<meta itemprop="wordCount" content="76">



<meta itemprop="keywords" content="" /><meta property="og:title" content="Php安装" />
<meta property="og:description" content="php安装  在./docker-compose中，增加service，实例如下
 version: &#34;3.7&#34;services:# php-fpmphp:image: devilbox/php-fpm:7.2-prodcontainer_name: &#34;php&#34;depends_on:- mysql- redisenvironment:- TZ=Asia/Shanghaivolumes:# 配置挂载到容器，在第一次启动容器后，复制出来，然后重建容器# - ./php/etc:/usr/local/etc# 数据卷挂载到容器- ./front:/front- ./back:/back# 以root方式启动command:- php-fpm- -Rlogging:driver: json-fileoptions:max-size: &#34;10M&#34;max-file: &#34;10&#34;restart: alwaysphp配置  修改php配置，使其以root角色启动，否则容易出现文件夹读写权限的问题
  容器php-fpm以root方式启动  command:- php-fpm- -R 修改./php/etc/php-fpm.conf  ############################################################; User and Group; ############################################################[www]user = rootgroup = root 配置." />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://www.lican.site/postsbak/php%E5%AE%89%E8%A3%85/" />
<meta property="article:published_time" content="2023-03-16T11:08:40+08:00" />
<meta property="article:modified_time" content="2023-03-16T11:08:40+08:00" />
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Php安装"/>
<meta name="twitter:description" content="php安装  在./docker-compose中，增加service，实例如下
 version: &#34;3.7&#34;services:# php-fpmphp:image: devilbox/php-fpm:7.2-prodcontainer_name: &#34;php&#34;depends_on:- mysql- redisenvironment:- TZ=Asia/Shanghaivolumes:# 配置挂载到容器，在第一次启动容器后，复制出来，然后重建容器# - ./php/etc:/usr/local/etc# 数据卷挂载到容器- ./front:/front- ./back:/back# 以root方式启动command:- php-fpm- -Rlogging:driver: json-fileoptions:max-size: &#34;10M&#34;max-file: &#34;10&#34;restart: alwaysphp配置  修改php配置，使其以root角色启动，否则容易出现文件夹读写权限的问题
  容器php-fpm以root方式启动  command:- php-fpm- -R 修改./php/etc/php-fpm.conf  ############################################################; User and Group; ############################################################[www]user = rootgroup = root 配置."/>

	<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
	<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
	<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
	<link rel="manifest" href="/site.webmanifest">
	<link rel="mask-icon" href="/safari-pinned-tab.svg" color="">
	<link rel="shortcut icon" href="/favicon.ico">

	<title>Php安装</title>
	<link rel="stylesheet" href="https://www.lican.site/css/style.min.d3141168199607bf3a517216ce3c263814eecdbc8fca72a9a88700799a838219.css">
	
</head>

<body id="page">
	
	<header id="site-header" class="animated slideInUp faster">
		<div class="hdr-wrapper section-inner">
			<div class="hdr-left">
				<div class="site-branding">
					<a href="https://www.lican.site">花落雨忧</a>
				</div>
				<nav class="site-nav hide-in-mobile">
					<a href="https://www.lican.site/posts">首页</a>
					<a href="https://www.lican.site/tech/">技术文档</a>
					<a href="https://www.lican.site/article/">文章</a>
					<a href="https://www.lican.site/project/">项目</a>
					<a href="https://www.lican.site/about/">关于</a>
				</nav>
			</div>
			<div class="hdr-right hdr-icons">
				<button id="menu-btn" class="hdr-btn" title="Menu"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-menu"><line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line></svg></button>
			</div>
		</div>
	</header>
	<div id="mobile-menu" class="animated fast">
		<ul>
			<li><a href="https://www.lican.site/posts">首页</a></li>
			<li><a href="https://www.lican.site/tech/">技术文档</a></li>
			<li><a href="https://www.lican.site/article/">文章</a></li>
			<li><a href="https://www.lican.site/project/">项目</a></li>
			<li><a href="https://www.lican.site/about/">关于</a></li>
		</ul>
	</div>


	<main class="site-main section-inner thin animated fadeIn faster">
		<h1>Php安装</h1>
		<div class="content">
			<h3 id="php安装">php安装<a href="#php安装" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path><line x1="8" y1="12" x2="16" y2="12"></line></svg></a></h3>
<blockquote>
<p>在./docker-compose中，增加service，实例如下</p>
</blockquote>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go"><span style="color:#a6e22e">version</span>: <span style="color:#e6db74">&#34;3.7&#34;</span>
<span style="color:#a6e22e">services</span>:
  <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">php</span><span style="color:#f92672">-</span><span style="color:#a6e22e">fpm</span>
  <span style="color:#a6e22e">php</span>:
    <span style="color:#a6e22e">image</span>: <span style="color:#a6e22e">devilbox</span><span style="color:#f92672">/</span><span style="color:#a6e22e">php</span><span style="color:#f92672">-</span><span style="color:#a6e22e">fpm</span>:<span style="color:#ae81ff">7.2</span><span style="color:#f92672">-</span><span style="color:#a6e22e">prod</span>
    <span style="color:#a6e22e">container_name</span>: <span style="color:#e6db74">&#34;php&#34;</span>
    <span style="color:#a6e22e">depends_on</span>:
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">mysql</span>
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">redis</span>
    <span style="color:#a6e22e">environment</span>:
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">TZ</span>=<span style="color:#a6e22e">Asia</span><span style="color:#f92672">/</span><span style="color:#a6e22e">Shanghai</span>
    <span style="color:#a6e22e">volumes</span>:
      <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">配置挂载到容器</span><span style="color:#960050;background-color:#1e0010">，</span><span style="color:#a6e22e">在第一次启动容器后</span><span style="color:#960050;background-color:#1e0010">，</span><span style="color:#a6e22e">复制出来</span><span style="color:#960050;background-color:#1e0010">，</span><span style="color:#a6e22e">然后重建容器</span>
      <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#f92672">-</span> .<span style="color:#f92672">/</span><span style="color:#a6e22e">php</span><span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span>:<span style="color:#f92672">/</span><span style="color:#a6e22e">usr</span><span style="color:#f92672">/</span><span style="color:#a6e22e">local</span><span style="color:#f92672">/</span><span style="color:#a6e22e">etc</span>
      <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">数据卷挂载到容器</span>
      <span style="color:#f92672">-</span> .<span style="color:#f92672">/</span><span style="color:#a6e22e">front</span>:<span style="color:#f92672">/</span><span style="color:#a6e22e">front</span>
      <span style="color:#f92672">-</span> .<span style="color:#f92672">/</span><span style="color:#a6e22e">back</span>:<span style="color:#f92672">/</span><span style="color:#a6e22e">back</span>
    <span style="color:#960050;background-color:#1e0010">#</span> <span style="color:#a6e22e">以root方式启动</span>
    <span style="color:#a6e22e">command</span>:
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">php</span><span style="color:#f92672">-</span><span style="color:#a6e22e">fpm</span>
      <span style="color:#f92672">-</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">R</span>
    <span style="color:#a6e22e">logging</span>:
      <span style="color:#a6e22e">driver</span>: <span style="color:#a6e22e">json</span><span style="color:#f92672">-</span><span style="color:#a6e22e">file</span>
      <span style="color:#a6e22e">options</span>:
        <span style="color:#a6e22e">max</span><span style="color:#f92672">-</span><span style="color:#a6e22e">size</span>: <span style="color:#e6db74">&#34;10M&#34;</span>
        <span style="color:#a6e22e">max</span><span style="color:#f92672">-</span><span style="color:#a6e22e">file</span>: <span style="color:#e6db74">&#34;10&#34;</span>
    <span style="color:#a6e22e">restart</span>: <span style="color:#a6e22e">always</span>
</code></pre></div><h1 id="php配置">php配置<a href="#php配置" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path><line x1="8" y1="12" x2="16" y2="12"></line></svg></a></h1>
<blockquote>
<p>修改php配置，使其以root角色启动，否则容易出现文件夹读写权限的问题</p>
</blockquote>
<ul>
<li>容器php-fpm以root方式启动</li>
</ul>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go">    <span style="color:#a6e22e">command</span>:
      <span style="color:#f92672">-</span> <span style="color:#a6e22e">php</span><span style="color:#f92672">-</span><span style="color:#a6e22e">fpm</span>
      <span style="color:#f92672">-</span> <span style="color:#f92672">-</span><span style="color:#a6e22e">R</span>
</code></pre></div><ul>
<li>修改./php/etc/php-fpm.conf</li>
</ul>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go"><span style="color:#960050;background-color:#1e0010">############################################################</span>
; <span style="color:#a6e22e">User</span> <span style="color:#a6e22e">and</span> <span style="color:#a6e22e">Group</span>
; <span style="color:#960050;background-color:#1e0010">############################################################</span>

[<span style="color:#a6e22e">www</span>]
<span style="color:#a6e22e">user</span>  = <span style="color:#a6e22e">root</span>
<span style="color:#a6e22e">group</span> = <span style="color:#a6e22e">root</span>
</code></pre></div><ul>
<li>配置./php/etc/php/php.ini,避免木马攻击</li>
</ul>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-go" data-lang="go"><span style="color:#a6e22e">disable_functions</span> = <span style="color:#a6e22e">assert</span>,<span style="color:#a6e22e">system</span>,<span style="color:#a6e22e">passthru</span>,<span style="color:#a6e22e">shell_exec</span>,<span style="color:#a6e22e">exec</span>,<span style="color:#a6e22e">popen</span>
</code></pre></div>
		</div>
	</main>

	<footer id="site-footer" class="section-inner thin animated fadeIn faster">
		<p>&copy; 2024 <a href="https://www.lican.site"></a></p>
		<p>
			Made with <a href="https://gohugo.io/" target="_blank" rel="noopener">Hugo</a> &#183; Theme <a href="https://github.com/Track3/hermit" target="_blank" rel="noopener">Hermit</a> &#183; <a href="https://www.lican.site/post/index.xml" target="_blank" title="rss"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-rss"><path d="M4 11a9 9 0 0 1 9 9"></path><path d="M4 4a16 16 0 0 1 16 16"></path><circle cx="5" cy="19" r="1"></circle></svg></a>
		</p>
	</footer>


	<script src="https://www.lican.site/js/main.min.784417f5847151f848c339cf0acb13a06cbb648b1483435a28ed4556c4ead69b.js"></script>

</body>

</html>
